package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.GongzuoRzBaoxiaoModel;

/**
 * @author liyc
 * @time 2012-3-30 下午2:03:41
 * @annotation 
 */
public class GetCCQKTask extends Task{

	public GetCCQKTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {

		String ccguid = getParam().get("ccguid").toString();
		String rzdate = getParam().get("rzdate").toString();
		String gzrzguid = getParam().get("gzrzguid").toString();
		String userguid = getCon().fp.getUserguid();

		String seamurl = getCon().fp.generateUrl("EpointGetCCQK",ccguid,rzdate,userguid,gzrzguid);
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}


	public static List<GongzuoRzBaoxiaoModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<GongzuoRzBaoxiaoModel> plist = new ArrayList<GongzuoRzBaoxiaoModel>();
		for (int i = 0; i < focs.size(); i++) {
			GongzuoRzBaoxiaoModel mt = new GongzuoRzBaoxiaoModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("xh") != null)
				mt.xh = foc.elementText("xh");
			if (foc.element("BXType") != null)
				mt.BXType = foc.elementText("BXType");
			if (foc.element("BXTypeStr") != null)
				mt.BXTypeStr = foc.elementText("BXTypeStr");
			if (foc.element("BXMoney") != null)
				mt.BXMoney = foc.elementText("BXMoney");
			if (foc.element("FaShengDi") != null)
				mt.FaShengDi = foc.elementText("FaShengDi");
			if (foc.element("Remarks") != null)
				mt.Remarks = foc.elementText("Remarks");
			plist.add(mt);
		}
		return plist;
	}

}
